package com.fengmi.controller;

import com.fengmi.dto.GoodsDTO;
import com.fengmi.dto.PageDTO;
import com.fengmi.entity.MallGoods;
import com.fengmi.service.GoodsService;
import com.fengmi.view.ViewGoodsInfo;
import com.fengmi.vo.PageResultVO;
import com.fengmi.vo.ResultVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author 123
 * @Date 2022/1/25 9:34
 * @Version 1.0
 */

@RestController
@RequestMapping("goods")
@Api(tags = "商品管理")
@CrossOrigin
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @PostMapping("page")
    @ApiOperation("商品分页及条件查询")
    public PageResultVO<MallGoods> findPage(@RequestBody PageDTO<MallGoods> pageDTO) {
        return goodsService.findGoodsByPageAndWhere(pageDTO);
    }


    @PostMapping("page1")
    @ApiOperation("商品分页及条件查询")
    public PageResultVO<ViewGoodsInfo> findPage1(@RequestBody PageDTO<MallGoods> pageDTO) {



        return goodsService.findGoodsByPage(pageDTO);
    }



    @PostMapping("save")
    public ResultVO findPage1(@RequestBody GoodsDTO goodsDTO) {

        return goodsService.save(goodsDTO);
    }
}